package com.itheima.controller;

import com.itheima.service.OrderSettingService;
import com.itheima.utils.POIUtils;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author jshstart
 * @creat 2020-11-15 13:05
 */
@RestController
@RequestMapping("/ordersetting")
public class OrderSettingController {
    @Reference
    private OrderSettingService orderSettingService;
    @RequestMapping("/importData")
    public Boolean importData(@RequestParam("file")MultipartFile multipartFile) throws IOException {
        List<String[]> list = POIUtils.readExcel(multipartFile.getInputStream(),multipartFile.getOriginalFilename());
        System.out.println("list = " + list);
        return orderSettingService.importData(list);
    }
    @GetMapping("findAllByYearMonth/{year}/{month}")
    public Map findAllByYearMonth(@PathVariable("year") String year,@PathVariable("month") String month){
        System.out.println("year = " + year+"   month:"+month);
       return orderSettingService.findAllByYearMonth(year,month);
    }
    @GetMapping("settingDialog/{settindDay}/{number}")
    public boolean settingDialog(@PathVariable("settindDay") String settindDay,@PathVariable("number")String number){
        System.out.println("settindDay = " + settindDay);
        return   orderSettingService.settingDialog(settindDay,number);
    }
}
